package com.cn.study009;

import java.util.Scanner;

/**
 * @author lw
 * @ClassName Demo003.java
 * @Description
 * @createTime 2023年05月14日
 */
public class Demo003 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String str = null;
        String user =null;
        String password = null;
        int max = 9999;
        int min = 1000;
        String mark = null;
        do {
            System.out.println("*****欢迎进入奖客富翁系统*****");
            System.out.println("\t\t1.注册");
            System.out.println("\t\t2.登录");
            System.out.println("\t\t3.抽奖");
            System.out.println("*****************************");
            System.out.print("请选择菜单：");
            int n = sc.nextInt();
            switch (n) {
                case 1:
                    System.out.println("奖客富翁系统> 注册");
                    System.out.println("请填写个人注册信息：");
                    System.out.print("用户名：");
                    user = sc.next();
                    System.out.print("密码：");
                    password = sc.next();
                    if (user != null && password != null) {
                        mark = "true";
                        System.out.println("注册成功，请记住您的会员卡号");
                        int cardNumber = (int) (Math.random() * (max - min)) + min;
                        System.out.println("用户名\t\t密码\t\t会员卡号");
                        System.out.println(user + "\t\t" + password + "\t\t" + cardNumber);
                    } else {
                        mark = "false";
                    }
                    break;
                case 2:
                    System.out.println("奖客富翁系统> 登录");
                    for (int i = 1; i <=3 ; i++) {
                        System.out.print("请输入用户名：");
                        String u=sc.next();
                        System.out.print("请输入密码：");
                        String p=sc.next();

                        if (u.equals(user)&&p.equals(password)){
                            System.out.println("欢迎您，"+user);
                            break;
                        }else if(i<3){
                            System.out.println("用户名或密码错误，请重新输入：");
                        }else {
                            System.out.println("超过三次，登录失败！");
                        }
                    }
                    break;
                case 3:
                    System.out.println("奖客富翁系统> 抽奖");
                    break;
                default:
                    System.out.println("您的输入有误！");
            }
            System.out.print("继续吗？(y/n)");
            str = sc.next();
        } while (str.equals("y"));

        System.out.println("\n系统退出，谢谢使用！");
    }
}
